package PackageOfDoom;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class MenuMaker extends Application {

    int menu = 0;
    Button alpha = new Button("E&M");
    Button beta = new Button("Waves");
    Button gamma = new Button("Mechanics");
    Button theta = new Button("Exit");
    Text title = new Text("Welcome to Science");
    VBox all = new VBox();

    public static void main(String[] args) {
        launch();
    }

    @Override
    public void start(Stage stage) {
        
        alpha.setPrefSize(500, 50);
        beta.setPrefSize(500, 50);
        gamma.setPrefSize(500, 50);
        theta.setPrefSize(500, 50);
        
        alpha.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent t) {
                switch (menu) {
                   case 0:
                        SetButtonText("Ohm", "Magnets", "In Construction", "Back");
                        title.setText("Electricity and Magnetism");
                        menu = 1;
                        break;
                   case 1:
                        SetButtonText("Run E&M Animation 1", "Run E&M Animation 1", "Run E&M Animation 1", "Back");
                        title.setText("Electricity and Magnetism");
                        break;
                   case 2:
                        SetButtonText("Run Waves Animation 1", "Run  Waves Animation 1", "Run Waves Animation 1", "Back");
                        title.setText("Waves Optics and Modern Physics");                        
                        break;  
                   case 3:
                        SetButtonText("Run Mechanics Animation 1", "Run Mechanics Animation 1", "Run Mechanics Animation 1", "Back");
                        title.setText("Electricity and Magnetism");                     
                        break;
                 
                }
            }
        });

        beta.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent t) {
                switch (menu) {
                    case 0:
                        SetButtonText("S.H.M.", "Doppler Effect", "In Construction", "Back");
                        title.setText("Waves, Optics and Modern Physics");
                        menu = 2;
                        break;
                    case 1:
                        SetButtonText("Run E&M Animation 2", "Run E&M Animation 2", "Run E&M Animation 2", "Back");
                        title.setText("Electricity and Magnetism");
                        break;
                    case 2:
                        SetButtonText("Run Waves Animation 2 ", "Run Waves Animation 2", "Run Waves Animation 2", "Back");
                        title.setText("Waves Optics and Modern Physics");
                        break;
                    case 3:
                        SetButtonText("Run Mechanics Animation 2", "Run Mechanics Animation 2", "Run Mechanics Animation 2", "Back");
                        title.setText("Electricity and Magnetism");
                        break;

                }
            }
        });

        gamma.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent t) {
                if (menu == 0) {
                    SetButtonText("Linear Motion", "Projectile Motion", "In Construction", "Back");
                    title.setText("Mechanics");
                    menu = 3;
                } else {
                    SetButtonText("In Construction", "In Construction", "In Construction", "Back");
                    title.setText("In Construction");   
                    menu = 5;
                }
            }
        });

        theta.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent t) {

                if (menu == 0) {
                    System.exit(0);

                } else {
                    SetButtonText("E&M", "Waves", "Mechanics", "Exit");
                    title.setText("Welcome to Science");
                    menu = 0;
                }
            }
        });

        title.setId("tiTLE");
        all.setAlignment(Pos.CENTER);
        all.setSpacing(10);
        all.getChildren().add(title);
        all.getChildren().add(alpha);
        all.getChildren().add(beta);
        all.getChildren().add(gamma);
        all.getChildren().add(theta);
        Scene menu = new Scene(all);
        menu.getStylesheets().add(MenuMaker.class.getResource("Style.css").toExternalForm());
        stage.setScene(menu);
        stage.setWidth(1500);
        stage.setHeight(700);
        stage.setTitle("It's Time for Science");
        stage.show();
    }

    public void SetButtonText(String a, String b, String c, String d) {
        alpha.setText(a);
        beta.setText(b);
        gamma.setText(c);
        theta.setText(d);
    }
}
